﻿$(function(){
	tabs('#basicInfo','#basicInfo > h3 a','#basicInfo > ul');
	$('#getMediaSourceList').submit(function(){getMediaSourceList(this); return false;});
	$('#addFavorites').click(function(){addFavorites(this); return false;});
	star('#star',$('#star .a').size());
	//$('#showImages img').beautyStyle({'align':'center','margin':'10px 0','type':'img'});
	
	delFile('a.actiondel',root_path+'?option=mylist&id='+user_id+'&page=1.html');
	
	$('#taskAttendForm').submit(function(){ addTaskAttend(this);return false; });
	
	$(".beautyImg").corner("8px") ;	
	$("#mediaShow h2 span a").corner("4px") ;
	//beautyImg('#talk div.userInfo img')
});

function getMediaSourceList(obj){
	var $info = $(obj).find('.info');
	$info.html(loading);
	$.post($(obj).attr('action')+'&dataType=ajax',{'mediaPassWord':$('#mediaPassWord').val()},function(data){	
		if(data.status == 'ok'){
			$(obj).hide().after(data.msg);
			$info.html('');
		}else{
			$info.html(data.msg).addClass('error').show();
		}
	},'json');
};


 
function addFavorites(obj){
	$.post($(obj).attr('href')+'&dataType=ajax',function(data){	
		if(data.status == 'ok'){
			//$(obj).hide().after(data.msg);
			$(obj).hide().after('<input class="submit disabled" value="已经收藏"  />');
		}else{
			alert(data.msg);
		}
	},'json');
};

function addTaskAttend(obj){
	var $obj = $(obj);
	var sendData = {task_id:$('#task_id').val()};
	$.post($obj.attr('action'),sendData,function(data){	
		$.openWin({'msg':data,onClose:function(){  window.location.reload(); }});
		$('#popupContact > .showMsg').find('div').removeClass();
	});
};
